<h1><?php echo __(ucfirst($action).' category'); ?></h1>

<form action="<?php echo get_url('plugin/pgallery/save_category') ?>" method="post">
	
	<input type="hidden" name="category[id]" value="<?php echo $category->id ?>" />
	
	<table class="fieldset" cellpadding="0" cellspacing="0" border="0">
		
		
		<!-- field: name -->
		<tr>
			<td class="label"><label for="name"><?php echo __('Name') ?></label></td>
			<td class="field"><input class="textbox" id="name" maxlength="50" name="category[name]" size="50" type="text" value="<?php echo $category->name ?>" /></td>
			<td class="help"><?php echo __('Required.'); ?></td>
		</tr>
		
		
		<!-- field: description -->
		<tr>
			<td class="label"><label for="description"><?php echo __('Description') ?></label></td>
			<td class="field"><textarea name="category[description]" id="description" class="textarea" rows="4"><?php echo $category->description ?></textarea></td>
			<td class="help" valign="top">A description to show what this category contains.</td>
		</tr>
		
		
		<!-- field: category -->
		<tr>
			<td class="label"><label for="category"><?php echo __('Parent category') ?></label></td>
			<td class="field"><select name="category[parent_id]" id="category">
				<option value="-1"<?php echo (empty($category->parent_id)) ? ' selected="selected"' : ''; ?>>(None)</option>
				<?php
				foreach($cats as $id => $name){
					$selected = ($category->parent_id == $id) ? 'selected="selected"' : '';
					echo sprintf('<option value="%s" %s>%s</option>', $id, $selected, $name);
				}
				?></select>
			</td>
			<td class="help" valign="top">Choose which parent category (if any) this category should belong to</td>
		</tr>
		
		
		<!-- field: visible -->
		<?php
		$checked = 'checked="checked"';
		$visible = $category->visible;
		if((int)$category->visible == (int)0){
			$checked = '';
		}
		?>
		<tr>
			<td class="label"><label for="visible"><?php echo __('Visible') ?></label></td>
			<td class="field"><input type="checkbox" name="category[visible]" id="visible" value="1" <?php echo $checked ?> /></td>
			<td class="help">Make sure this box is ticked if you want this category to show up on the main website.</td>
		</tr>
		
	</table>

	<p class="buttons">
	<input class="button" name="commit" type="submit" accesskey="s" value="<?php echo __('Save'); ?>" />
	<?php echo __('or'); ?> <a href="<?php echo get_url('plugin/pgallery') ?>"><?php echo __('Cancel'); ?></a>
	</p>

</form>


<script type="text/javascript">
// <![CDATA[
Field.activate('name');
// ]]>
</script>